#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
#include "Thread_Pool.hpp"
#include "Functions.hpp"

int main()
{
    // massagelog(DEBUG, "%d %s %c %lf", 123, "这是一条日志信息", 'x', 123.46);

    lode_func();
    lode_name();
    srand((unsigned int)time(nullptr));
    Thread_Pool<Task>* tp = Thread_Pool<Task>::Creat_Threadpool();
    tp->run();

    // 放任务
    while (true)
    {
        int x = rand() % 100 + 1;
        usleep(1000);
        int y = rand() % 100 + 1;

        // int type = rand() % 4;
        // tp.push_task(Task(x,y,type,func_v[type]));

        for (int i = 0; i < 4; ++i)
        {
            tp->push_task(Task(x, y, i, func_v[i]));
            // std::cout << "放了任务：" << x << name_v[i] << y << "=?" << std::endl;
            massagelog(NORMAL, "%s %s %d %s %d %s\n", 
                "主线程","放了任务：", x, name_v[i].c_str(), y, "=?");
        }
        sleep(1);
    }
    return 0;
}